home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig05_10.jar
/
Ch05
/
Fig05_10
/
Fig05_10.cpp
next >
Wrap
C/C++ Source or Header
|
1997-10-14
|
714b
|
31 lines
// Fig. 5.10: fig05_10.cpp
// Converting lowercase letters to uppercase letters
// using a non-constant pointer to non-constant data
#include <iostream.h>
#include <ctype.h>
void convertToUppercase( char * );
int main()
{
char string[] = "characters and $32.98";
cout << "The string before conversion is: " << string;
convertToUppercase( string );
cout << "\nThe string after conversion is: "
<< string << endl;
return 0;
}
void convertToUppercase( char *sPtr )
{
while ( *sPtr != '\0' ) {
if ( *sPtr >= 'a' && *sPtr <= 'z' )
*sPtr = toupper( *sPtr ); // convert to uppercase
++sPtr; // move sPtr to the next character
}
}